package com.gpframework.module.process.service.impl;

import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.TypeReference;
import com.gpframework.module.process.domain.req.GpProcessManagementUpdate;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gpframework.module.process.mapper.GpProcessManagementMapper;
import com.gpframework.module.process.domain.GpProcessManagement;
import com.gpframework.module.process.domain.vo.GpProcessManagementVo;
import com.gpframework.module.process.service.IGpProcessManagementService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import java.util.ArrayList;
import java.util.List;
/**
 * @ClassName GpProcessManagement
 * @Author gpframework
 * @Date 2023-12-20
 * @Version 1.0.0
 * @Description 加工商管理Service业务层处理
 */
@Service
public class GpProcessManagementServiceImpl extends ServiceImpl<GpProcessManagementMapper, GpProcessManagement> implements IGpProcessManagementService {

    /**
     * @Description 查询列表返回VO 用于返回给前端的列表接口
     * @Author gpframework
     * @Date 2023-12-20
     * @Param [lqw]
     * @Return List<GpProcessManagementVo>
     */
    @Override
    public List<GpProcessManagementVo> listVo(QueryWrapper<GpProcessManagement> lqw) {
        return this.baseMapper.listVo(lqw);
    }

    /**
     * @Description 通过查询详情VO 用于返回给前端的列详情接口
     * @Author gpframework
     * @Date 2023-12-20
     * @Param [id]
     * @Return GpProcessManagementVo
     */
    @Override
    public GpProcessManagementVo getVoById(Long id) {
        return this.baseMapper.getVo(id);
    }

    @Override
    public boolean edit(List<GpProcessManagementUpdate> list) {
        ArrayList<GpProcessManagement> gpProcessManagements = new ArrayList<>();
        
        for (GpProcessManagementUpdate gpProcessManagementUpdate : list) {
            GpProcessManagement gpProcessManagement = Convert.convert(new TypeReference<GpProcessManagement>() {}, gpProcessManagementUpdate);
            gpProcessManagements.add(gpProcessManagement);
        }

        return this.updateBatchById(gpProcessManagements);
    }
}
